/*常用消息*/
var msg = {
    SERVER_EXCEPTION: "服务器异常，请联系管理员",
    UPDATE_SUCCESS: "更新成功",
    ADD_SUCCESS: "添加成功",
    DELETE_SUCCESS: "删除成功"
};

/*ajax请求*/
var ajax = {
    post: function (url, data, successFn, errorFn, isAsync) {
        if (typeof data == 'function') {
            successFn = data;
            data = {};
        }
        if (typeof errorFn == 'undefined') {
            errorFn = function () {
                alert("服务器异常请联系管理员");
            }
        }
        if (typeof isAsync == 'undefined') {
            isAsync = true;
        }
        $.ajax({
            type: "post",
            url: url,
            data: data,
            async: isAsync,
            success: successFn,
            error: errorFn,
        });
    }
};

//加载框
var loading = {
    commonLoad: function () {
        var load = layer.msg("登陆中...", {
            icon: 16,
            time: 10000 * 1000,
            shade: 0.1
        });
        return load;
    },
    simpleLoad: function () {
        return layer.load(2, {
            shade: [0.1, '#fff']
        });
    }
};

var StringUtil = {
    //判断字符串是否为空
    isEmpty: function (obj) {
        if (typeof obj === "undefined" || obj === null || obj === "") {
            return true;
        } else {
            return false;
        }
    }
};

/**
 * dialog依赖layer
 */
var dialog = {
    iframe: function (title, width, height, url, confirmFn, top) {
        if (StringUtil.isEmpty(top)) {
            top = "auto"
        }
        layer.open({
            type: 2,
            title: title,
            shadeClose: false,
            btn: ["确定", "取消"],
            shade: 0.1,
            offset: top,
            area: [width, height],
            content: url,
            yes: confirmFn
        });
    },
    iframeInfo: function (width, height, url, top, destroyFn) {
        if (StringUtil.isEmpty(top)) {
            top = "auto"
        }
        if (typeof top == 'function') {
            destroyFn = top;
            top = "auto";
        }
        if (StringUtil.isEmpty(destroyFn)) {
            destroyFn = null;
        }
        layer.open({
            type: 2,
            title: false,
            shadeClose: false,
            scrollbar: false,
            offset: top,
            closeBtn: 0,
            shade: 0.1,
            area: [width, height],
            content: url,
            end: destroyFn
        });
    },
    info: function (title, width, height, id, top) {
        if (StringUtil.isEmpty(top)) {
            top = "auto"
        }
        layer.open({
            title: title,
            type: 1,
            skin: 'layui-layer-rim', //加上边框
            area: [width, height], //宽高
            content: $("#" + id),
            shade: 0.1,
            offset: top
        })
    }
};





